<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> 
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
com.jxtti.model.User userInfo = com.jxtti.utils.AuthUtil.getUserInfo(request);
String orgId=null;
if(userInfo.getDistrictId()==null || userInfo.getDistrictId().equals("0")){ //非超管
	orgId=userInfo.getOrgId().toString();
}

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=9" />
		<meta http-equiv="pragma" content="no-cache" />
		<title>科室介绍</title>
		<%@ include file="../../../common/Admin-list.jsp"%>
		<script type="text/javascript" src="<%=bpath %>Scripts/common/common.js"></script>  		
		<script type="text/javascript">
		$(function(){	
			
			var datagridUrl= '../DeptsIntroduce/list.json';
			
			if(<%=orgId %>!=null){ //是否管理员
				$("#orgId").combotree("setValue",<%=orgId %>);	
				$("#orgId").combotree('disable');				
			}
					
			//加载人员
			$('#dataGridList').datagrid({
				height:'495',
				rownumbers:true,//设置为true将显示行数					
				striped:true, //设置为true将交替显示行背景
				fitColumns:true,//设置为true将自动使列适应表格宽度以防止出现水平滚动
				animate:true,											
				idField:'id',//id字段	
				pagination : true,//分页控件
				pageSize : 10,
			    pageList : [10, 20, 30],
			    url : datagridUrl,//投稿审核
				loadMsg : '数据装载中......',
				singleSelect : true,//设置为 true，则只允许选中一行				
				columns:[[					          								
							{field:'id',hidden:true,editor:{type:'text'}},
							{field:'fk_orgId',hidden:true,width:120,align:'center',editor:{type:'text'}},
							{field:'name',title:'科室名称',width:100,align:'left',editor:{type:'text'},
								//预览
								formatter:function(value,row,index){																	
									var url="/SiteIndex/depart.htm?id="+(row.id).toString()+'&preview=yes';	
									return '<a href="<%=basePath%>'+url+'"  target="_blank" ><img src="<%=basePath %>pages/Admin/Images/search.gif" title="点击预览" style="margin-bottom:-3px"></a>&nbsp;'+value;
						    	}
							},
							{field:'duties',title:'主要职责',width:250,align:'left',editor:{type:'text'},},
							{field:'contact',title:'联系方式',width:100,align:'center',editor:{type:'text'}},															
							{field:'visible',title:'显示',width:40,align:'center',editor:{type:'text'},
							    formatter:function(value){ 
						    		if(value=="1"){
						    			ss='<span disabled="disabled"><input type="checkbox" checked="checked" disabled="disabled"></span> ';
						    		}else{
						    			ss='<span disabled="disabled"><input type="checkbox" disabled="disabled"></span> ';
						    		}
						    		return ss;
						    	 }
							}
						]] 
			});				
			
			
			
		});
		
		function addArticle(){ //新增文章  			
			if(<%=orgId %>!=null){ //非管理员
				var aj = $.ajax({  
	        	    url:'../DeptsIntroduce/queryAll.json',  
	        	    data:{  
	        	    	fk_orgId :<%=orgId %>
	        	    },  
	        	    type:'post',  
	        	    cache:false,  
	        	    dataType:'json',  
	        	    success:function(data) { 		        	    	
	        	    	if(data!=null&&data.length!=0){	        	    		
	        	    		$.messager.alert('系统提示', '该科室已经添加过了!', 'warning');	        	    		
	        	    	}else{
	        	    		art.dialog.open('../DeptsIntroduce/addInterface.htm?type=add',{
	        					title: '',
	        					lock:true,
	        				  	width: '80%',
	        				    height: '90%'												   												   
	        				});
	        	    	}
	        	     },  
	        	     error : function() {  
	        	          alert("异常！");  
	        	     }  
	        	});				
			}else{
				art.dialog.open('../DeptsIntroduce/addInterface.htm?type=add',{
					title: '',
					lock:true,
				  	width: '80%',
				    height: '90%'												   												   
				});
			}
      	}
		
		function editArticle(){ //修改文章  
			var row = $('#dataGridList').datagrid('getSelected');
			if (row) {					
				art.dialog.open('../DeptsIntroduce/updateInterface.htm?type=edit&id='+row.id,{
					title: '',
					lock:true,
				  	width: '80%',
				    height: '90%'												   												   
				});				
			}else{				
				$.messager.alert('系统提示', '请选择一行!', 'warning');
			}			
      	}
		
		function delArticle(){  //删除操作
			var row = $('#dataGridList').datagrid('getSelected');
			if (row) {				
				art.dialog({
					icon: 'question',	
					width:250,
				    content: '你确定删除该数据？',
				    ok: function () {
			    		$.ajax({
							type:'POST',
							dataType:'json',
							async:false,
							url:'../DeptsIntroduce/delete.json',
							data:{ids:row.id,delSub:true},
							success:function(data){
								if(data.success=true){									
									art.dialog.alert('删除成功！');
									window.location.reload();  									
								}else{
									art.dialog.alert('删除失败，请联系管理员！');
								}
							}
						});				    			
				    },
				    cancelVal: '取消',
				    cancel: true 
				});				
			}else{				
				$.messager.alert('系统提示', '请选择一行!', 'warning');
			}
      	} 
			
		</script>
		
	</head>
<body>		
		<div class="easyui-panel" fit="true" type="panel" border="false">			
		<table id="dataGridList" type="dataGrid"	data-options="toolbar:'#toolBar'">
		</table>		
		<div id="toolBar" style="height: auto;padding:0px;">
			<!--表单  搜索栏-->
			<div id="filter" class="module">					
				<ul>								
					<li id="liOrgId">
						<label>部门：</label>
						<select id="orgId" name="orgId" class="easyui-combotree" multiple style="width:250px;"   
        					data-options="url:'../district/findByPidAll.json',panelHeight:245"></select>						
					</li>		
					<li>
						<input type="button" class="btn btn-blue-h20-w2" value="查询" onclick="searchList()" />
					</li>
				</ul>
				<div class="clear"></div>
			</div>
			<!--表单  列表栏-->
			<div class="list module">
				<div class="hd">
					<h2 class="t">数据列表</h2>
					<span class="handle4filter" title="显示/隐藏查询条件"></span>
				</div>
				<div class="bd">
					<div id="toolbar">
						<ul id="buttonPlace">							
							<li>
								<a  href="javascript:addArticle()" class="icon add" hideFocus="false"><span class = "glyphicon glyphicon-plus" style="display:in-line"></span>增加</a>
							</li>
							<li>
								<a href="javascript:editArticle()" class="icon edit"  hideFocus="false"><span class = "glyphicon glyphicon-edit" style="display:in-line"></span>修改</a>
							</li> 				
							<li>
								<a href="javascript:delArticle()"  class="icon dele"  hideFocus="false"><span class = "glyphicon glyphicon-trash" style="display:in-line"></span>删除</a>
							</li>							
						</ul>
					</div>
				</div>
			</div>
		</div>		
		<div id="win"></div>
	</div>
	<script type="text/javascript">	
		
	function searchList() {
		var queryParams = $('#dataGridList').datagrid('options').queryParams;		
		queryParams.fk_orgId=$("#orgId").combotree("getValues").join(',');			
		$('#dataGridList').datagrid('load');
		$('#dataGridList').datagrid('clearSelections');
	}
	
	$(function() {
		
	});
	
	</script>
</body>
</html>